package cn.edu.sdjzu.xg.bysj.security;


import cn.edu.sdjzu.xg.bysj.dao.ActorDao;
import cn.edu.sdjzu.xg.bysj.domain.User;
import cn.edu.sdjzu.xg.bysj.exception.BysjException;
import cn.edu.sdjzu.xg.bysj.util.JdbcHelper;

import java.sql.Connection;
import java.sql.SQLException;

public final class ActorService {
    private static final ActorDao actorDao = ActorDao.getInstance();
    private static final ActorService actorService = new ActorService();


    public static ActorService getInstance() {
        return actorService;
    }





    public int add(Connection connection) throws SQLException {
       return actorDao.add(connection);
    }
    public Actor find(Connection connection, int id) throws SQLException, BysjException {
        return actorDao.find(connection, id);
    }
    public Actor find(Integer id) throws SQLException, BysjException {
        Connection connection = JdbcHelper.getConn();
        Actor actor = actorDao.find(connection, id);
        JdbcHelper.close(connection);
        return actor;
    }
    public Actor login(User userToLogin) throws SQLException, BysjException {
        Connection connection = JdbcHelper.getConn();
        Actor actor = actorDao.login(connection, userToLogin);
        JdbcHelper.close(connection);
        return actor;
    }
}
